package www.bd.com.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import www.bd.com.dao.ArticleDao;
import www.bd.com.pojo.Article;

/**
 * @author Berret
 * @date 2019/4/16 15:09
 * @discription :
 */
@Service
public class ArticleService {

    @Autowired
    private ArticleDao articleDao;

    /**
     * 增加文章
     * @param article
     */
    public void add(Article article){
        articleDao.save(article);
    }

    public Page<Article> searchArticle(int page, int size, String keywords) {
        PageRequest pageRequest = PageRequest.of(page, size);
        return articleDao.findByTitleOrContentLike(keywords,pageRequest);
    }
}
